import * as prettier from "prettier";
import { DistStruct } from "../../../common/src/CreateDist";
import fs from "fs";
import path from "path";
export class Beautify {
  dist: DistStruct;
  constructor(dist: DistStruct) {
    this.dist = dist;
    this.index();
  }

  async index() {
    const filePath = path.join(this.dist.getRootPath(), "index.html");
    const html = fs.readFileSync(filePath).toString();

    const newForm = await prettier.format(html, {
      semi: false,
      parser: "html",
    });

    // console.log("write beauty");

    fs.writeFileSync(filePath, newForm);
  }
}
